<?php
/**
 * Created by PhpStorm.
 * User: luzhaoyang
 * Date: 2017/7/4
 * Time: 14:42
 * 统计控制器
 */
require_once APPPATH.'third_party/PHPExcel/PHPExcel/IOFactory.php';
class Stat extends Base_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('stat_model');
    }

    public function commlogin($start,$end)
    {
        if (!is_cli()) die('request forbidden');
        set_time_limit(0);
        $this->stat_model->commlogin($start,$end);
    }

    public function fmdkread()
    {
        if (!is_cli()) die('request forbidden');
        set_time_limit(0);
        $books='30.37.38.39.40.41.42.43.44.45.46.47.48.49';
        $this->stat_model->fmdkread($books);
    }

    public function share()
    {
        if (!is_cli()) die('request forbidden');
        set_time_limit(0);
        $this->stat_model->share();
    }

    public function saveFmdkstatData($start,$end)
    {
        if (!is_cli()) die('request forbidden');
        set_time_limit(0);
        $books='30.37.38.39.40.41.42.43.44.45.46.47.48.49';
        $this->stat_model->saveFmdkstatData($start,$end,$books);

    }

    public function createFmdkExcel()
    {
        $this->load->model('excelproc_model');
        $data = $this->excelproc_model->getFmdkData();
        $obj = new PHPExcel();
        $obj->getActiveSheet()->fromArray($data,'','A1');
        $objw = new PHPExcel_Writer_Excel2007($obj);
        $objw->save("fmdk-20170606-20170724-data.xlsx");
        echo 'fmdk-20170606-20170724-data.xlsx comlpete'.PHP_EOL;
    }
}